
//setCookie
export function setCookie(key,value,expire="") {
    // 有效时间
    var exdate = new Date();
    expire = expire || 24 * 60 * 60 * 1000 * 36500;
    exdate.setTime(exdate.getTime() + expire);
    // set
    window.document.cookie = key + "=" + value + ";path=/;expires=" + exdate.toGMTString();
}

// getCookie
export function getCookie(key) {
    var c_param = '';
    if (document.cookie.length > 0) {
        console.log(document.cookie);
        var arr = document.cookie.split('; '); //这里显示的格式需要切割一下自己可输出看下

        for (var i = 0; i < arr.length; i++) {
            // key => value
            var arr2 = arr[i].split('=');
            // 判断查找相对应的值
            if (arr2[0] == key) {
                c_param = arr2[1];
            }
        }
    }
    return c_param;
}
